GtkPlacesSidebar: Don't pile up duplicate bookmarks
authorMatthias Clasen <mclasen@redhat.com>
Sun, 5 Oct 2014 17:34:28 +0000 (13:34 -0400)
committerMatthias Clasen <mclasen@redhat.com>
Sun, 5 Oct 2014 17:39:37 +0000 (13:39 -0400)
We get multiple notifications from the bookmark manager when
something changes. Every time, we reconstruct the sidebar contents
completely, by clearing the store. The bookmarks are added with
async calls though, and the code was forgetting to cancel outstanding
async requests, leading to multiple instances of the same bookmark
getting added. Use the cancellable we already have to prevent that.

This could be made much more efficient by not recreating the entire
sidebar quite so often (3-5 times for a single bookmark rename).

https://bugzilla.gnome.org/show_bug.cgi?id=737679

gtk/gtkplacessidebar.c

index 2579fcf1e574d3cec065f45290546fc5341c82d8..108d3c7c9243102ff36aafed584a54a690e491e4 100644 (file)
@@ -915,6 +915,11 @@ update_places (GtkPlacesSidebar *sidebar)
   else
     original_uri = NULL;
 
+  g_cancellable_cancel (sidebar->cancellable);
+
+  g_object_unref (sidebar->cancellable);
+  sidebar->cancellable = g_cancellable_new ();
+
   gtk_list_store_clear (sidebar->store);
 
   sidebar->devices_header_added = FALSE;